package com.stone.controller;

import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.stone.po.Memo;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@Api(tags = "HutoolExcelController", description = "EasyExcel导入导出测试")
@RequestMapping("/hutoolExcel")
public class HutoolExcelController {

    @GetMapping(value = "/readExtel")
    public static void exportMemberList() {
        ExcelReader reader = ExcelUtil.getReader("E:/memo2.xlsx");
        List<Memo> memoList = reader.readAll(Memo.class);
        System.err.println(memoList.size());
        // UPDATE MemoData.dbo.Memo set SourceId = 61390 WHERE MemoTypeCode = 'A000000000000002' AND SourceId = 107040;
        // UPDATE UserData.dbo.User2 set Email = 'teshayoung@ymail.com',LastModifiedAt = GETDATE(), LastModifiedBy = 599937 WHERE UserId = 712251;
        // UPDATE MemoData.dbo.Memo set SourceId = 61390, LastModifiedAt = GETDATE(), LastModifiedBy = 599937 WHERE MemoTypeCode = 'A000000000000002' AND SourceId = 107040;

        memoList.stream().forEach(r -> {
            System.err.println("UPDATE MemoData.dbo.Memo set SourceId = " + r.getRealsureQuoteId() + ", LastModifiedAt = GETDATE(), LastModifiedBy = 599937 WHERE MemoTypeCode = 'A000000000000002' AND SourceId = " + r.getConsumerUserId() + ";");
        });


    }

    public static void main(String[] args) throws InterruptedException {
        Thread.sleep(10000000);
        exportMemberList();
    }
}


